using IQIGame.Onigao.Game;
using IQIGame.Onigao.GamePlay;

namespace IQIGame.Onigao.Logic
{
    /// <summary>
    /// 修改交互类型（交互类型用于显示交互按钮样式，说明该实体是可对话的还是可攻击的，可调查的等等）
    /// 参数：1：实体tag（填0表示自己），2：交互类型
    /// </summary>
    public class ExecChangeInteractType : BaseServiceExecution
    {
        public override void Execute(LevelRegion region, LevelPlayer player)
        {
            var config = _config as ExecParamChangeInteractType;
            var entities = ListPool<LevelEntity>.Get();
            if (!LgLevelEntityUtil.GetEntitiesByDynCfgKeys(region, triggerEntity, config.tagOrMcid, entities))
            {
                ListPool<LevelEntity>.Put(entities);
                return;
            }

            byte interactType = config.interactType;

            foreach (var entity in entities)
            {
                entity.SetInteractType(interactType, false);
            }

            region.UpdateEntities(player, entities);

            ListPool<LevelEntity>.Put(entities);
        }
    }
}
